import myHelper from "@mods/utils/helper";
import {
    SOCIAL_HOST_STUB_THEBIZARK,
    SOCIAL_HOST_STUB_BIZARKDEV,
    SOCIAL_HOST_STUB_QLINYUN,
    SOCIAL_HOST_STUB_QLINYUNDEV,
    SOCIAL_VENDOR_DINGTALK,
    SOCIAL_VENDOR_WECHAT,
    SOCIAL_VENDOR_WECHAT_OPEN,
    SOCIAL_VENDOR_WECHAT_MP,
    SOCIAL_VENDOR_WECHAT_ENTERPRISE,
    SOCIAL_VENDOR_THEBIZARK,
    SOCIAL_VENDOR_BIZARKDEV,
    SOCIAL_VENDOR_QLINYUN,
    SOCIAL_VENDOR_QLINYUNDEV,
} from "@mods/service/base";
import BizConstants from '../common/BizConstants/index'
const util = {
    /**
     * 根据所属host输出可以被展示的三方登录标识列表
     * @param {String} host
     */
    getAvailableSourcesByHost(host) {
        if (host) {
            this.getOutputSourceLabelByHost(host);
            if (myHelper.hostStubMatch(host, SOCIAL_HOST_STUB_THEBIZARK)) {
                return [
                    BizConstants.SOCIAL_SOURCE_MAP[SOCIAL_VENDOR_DINGTALK],
                ];
            } else if (myHelper.hostStubMatch(host, SOCIAL_HOST_STUB_QLINYUN)) {
                if(myHelper.hostStubMatch(host, SOCIAL_HOST_STUB_QLINYUNDEV) && (
                    myHelper.hostStubMatch(host, "my-port.qlinyun.com")
                    || myHelper.hostStubMatch(host, "my-port.qlinyun.com:8443")
                    || myHelper.hostStubMatch(host, "local-port.qlinyun.com:8443")
                    || myHelper.hostStubMatch(host, "local-port.qlinyun.com")
                    || myHelper.hostStubMatch(host, "dev-port.qlinyun.com")
                    || myHelper.hostStubMatch(host, "test-port.qlinyun.com")
                    || myHelper.hostStubMatch(host, "stage-port.qlinyun.com")
                )){
                    return [
                        BizConstants.SOCIAL_SOURCE_MAP[SOCIAL_VENDOR_QLINYUNDEV],
                    ];
                }else{
                    return [
                        BizConstants.SOCIAL_SOURCE_MAP[SOCIAL_VENDOR_QLINYUN],
                    ];
                }
            }
        }
        return [];
    },
    getIsQilinYunHost(host) {
        return myHelper.hostStubMatch(host, SOCIAL_HOST_STUB_QLINYUN);
    }
    /**
     * 根据host更改展示标签
     *
     */
    , getOutputSourceLabelByHost(host) {

    }
    /**
     * 检测是否展示社交登录
     * @param {String} host
     */
    , checkSocialLogin(host) {
        let sources = this.getAvailableSourcesByHost(host);
        return sources.length > 0;
    },
    /**
     * 获取地址栏hash中的token
     * @param {string} key
     */
    getHashToken(url, key = 'token') {
        return myHelper.getUrlHashParam(url, key);
    },
}

export default util;
